package com.spring.sunflower.common

import com.spring.sunflower.base.BaseObserver
import com.spring.sunflower.base.BasePresenter
import com.spring.sunflower.bean.AuthCodeBean
import com.spring.sunflower.bean.BlackHasBean

/**
 * Created by Kevin on 2021/8/28<br/>
 *
 * Describe:<br/>
 */
class BindPhonePresenter(baseView: CommonContract.BindPhoneView):BasePresenter<CommonContract.BindPhoneView>(baseView) {
    fun bindPhone(phoneNum: String,code:String) {
        val observable = requestDataSource.bindPhoneFruit(phoneNum,code)
        addDisposable(observable, object : BaseObserver<BlackHasBean>(baseView) {
            override fun onSuccess(bean: BlackHasBean) {
                baseView.bindSuccess()
            }

            override fun onError(status: Int, msg: String?) {
            }
        })
    }
    fun requestAuthCode(phoneNum: String, type: String) {
        val observable = requestDataSource.requestAuthCode(phoneNum, type)
        addDisposable(observable, object : BaseObserver<AuthCodeBean?>(baseView) {
            override fun onSuccess(bean: AuthCodeBean?) {
                baseView.requestFinish()
            }

            override fun onError(status: Int, msg: String) {
//                baseView.showError(status, msg)
            }
        })
    }
}